package Padre::Document::Moose;

=head1 NAME

Padre::Document::Moose - Padre Document API for Moose

=cut

use 5.008;

use strict;
use warnings;

our $VERSION = '0.01';

use base 'Padre::Document::Perl';


sub get_outline {
        my $self = shift;
        my %args = @_;

        my $text = $self->text_get;
        unless ( defined $text and $text ne '' ) {
                return [];
        }

        # Do we really need an update?
        require Digest::MD5;
        my $md5 = Digest::MD5::md5_hex( Encode::encode_utf8($text) );
        unless ( $args{force} ) {
                if ( defined( $self->{last_outline_md5} )
                        and $self->{last_outline_md5} eq $md5 )
                {
                        return;
                }
        }
        $self->{last_outline_md5} = $md5;

        my %check = (
                editor => $self->editor,
                text   => $text,
        );
        if ( $self->project ) {
                $check{cwd}      = $self->project->root;
                $check{perl_cmd} = ['-Ilib'];
        }

        require Padre::Task::Outline::Moose;
        my $task = Padre::Task::Outline::Moose->new(%check);

        # asynchronous execution (see on_finish hook)
        $task->schedule;
        return;
}


1;


=head1 AUTHOR

Piotr Roszatycki <dexter@cpan.org>

=head1 LICENSE

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl 5 itself.
